package com.zsyh.jiujiu.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.yanzhenjie.kalle.Kalle;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @ProjectName: livvehelp
 * @Package: com.zsyh.lsb.ui
 * @ClassName:
 * @Description: java类作用描述
 * @Author: zsyh
 * @CreateDate: 2020/9/7 11:59
 * @UpdateUser: liangwanbo
 * @UpdateDate: 2020/9/7 11:59
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public abstract class BaseNewFragment extends Fragment {

    protected Activity mActivity;
    protected Unbinder mUnbinder;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        mActivity = (Activity) context;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(initLayout(), container, false);
        mUnbinder = ButterKnife.bind(this, rootView);
        initView(rootView);
        initData();
        return rootView;

    }

    protected abstract int initLayout();
    protected abstract void initView(View rootView);

    protected abstract void initData();


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Kalle.cancel(this);
        if (mUnbinder != null) {
            mUnbinder.unbind();
        }

    }

}
